##----- Causal Effects on the Mediators
load("result_Mediators")

index1 <- seq(1,1198,by=3); index2 <- seq(2,1199,by=3); index3 <- seq(3,1200,by=3)
# Means : SO2, NOx and CO2
(Mean.SO2 <- mean(apply(result, 1, mean)[index1]))
(Mean.NOx <- mean(apply(result, 1, mean)[index2]))
(Mean.CO2 <- mean(apply(result, 1, mean)[index3]))
# 95% C.I.s : SO2, NOx and CO2
(Lo.SO2 <- sort(apply(result, 1, mean)[index1])[400*0.025])
(Up.SO2 <- sort(apply(result, 1, mean)[index1])[400*0.975])
(Lo.NOx <- sort(apply(result, 1, mean)[index2])[400*0.025])
(Up.NOx <- sort(apply(result, 1, mean)[index2])[400*0.975])
(Lo.CO2 <- sort(apply(result, 1, mean)[index3])[400*0.025])
(Up.CO2 <- sort(apply(result, 1, mean)[index3])[400*0.975])





##----- Causal Indirect and Direct Effects
load("result_Effects")

# Means : TE, JNIE123, NDE, NIE1, NIE2, NIE3, JNIE12, JNIE23, JNIE13
(Means <- apply(result, 2, mean))
# 95% C.I.s :
(Lo <- apply(result, 2, function(x) sort(x)[dim(result)[1]*0.025]))
(Up <- apply(result, 2, function(x) sort(x)[dim(result)[1]*0.975]))





##----- Principal Causal Effects
load("result_PS")

# Means : SO2, NOx, CO2, SO2&NOx, SO2&CO2, NOx&CO2, SO2&NOx&CO2
(Means.EAE1 <- apply(result[,1:7], 2, mean))
(Means.EDE <- apply(result[,8:14], 2, mean))
(Means.EAE2 <- apply(result[,15:21], 2, mean))
# 95% C.I.s :
(Lo.EAE1 <- apply(result[,1:7], 2, function(x) sort(x)[dim(result)[1]*0.025]))
(Up.EAE1 <- apply(result[,1:7], 2, function(x) sort(x)[dim(result)[1]*0.975]))
(Lo.EDE  <- apply(result[,8:14], 2, function(x) sort(x)[dim(result)[1]*0.025]))
(Up.EDE  <- apply(result[,8:14], 2, function(x) sort(x)[dim(result)[1]*0.975]))
(Lo.EAE2 <- apply(result[,15:21], 2, function(x) sort(x)[dim(result)[1]*0.025]))
(Up.EAE2 <- apply(result[,15:21], 2, function(x) sort(x)[dim(result)[1]*0.975]))


